home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / comm / fido / shelter191a.lha / rexx / X.REXX < prev    next >
OS/2 REXX Batch file  |  1994-06-13  |  2KB  |  85 lines

  1. /**/
  2. v="$VER: X  Rexx  Automatic archive detection and extraction          50.00"
  3. packer.     = ""        ; cmd.      = ""
  4. packer.arc  = "pkxarc"  ; cmd.arc   = "-e"
  5. packer.zoo  = "Zoo"     ; cmd.zoo   = "x.//"
  6. packer.lha  = "lha"     ; cmd.lha   = "-x0 -M e"
  7. packer.zip  = "unzip"   ; cmd.zip   = "-xjn "
  8. packer.arj  = "unarj"   ; cmd.arj   = "e"
  9. packer.ape  = "ape"     ; cmd.ape   = "x"
  10.  
  11. trace background
  12. options failat 10
  13.  
  14. signal on halt
  15. signal on ioerr
  16. signal on break_c
  17.  
  18. log=show('P','ROOFLOG')
  19. sv="v"||right(v,5)
  20. script='X'
  21.  
  22. if arg() = 0 then exit 10
  23.  
  24. if GetClip('ASYNC') = 'TRUE' then do
  25. wspec = 'RAW:0/10/640/30/ROOF 'script sv'/INACTIVE/AUTO/SCREEN'||GetClip('ASYNCSCREEN')
  26. close('STDOUT');open('STDOUT',wspec,'w')
  27. end
  28. call close 'STDIN';call open 'STDIN','*','R'
  29. parse upper arg file files
  30. PutLog("Scanning "file "spec:"files,10,10)
  31. if ~open('in', file, 'R') then do
  32. PutLog("Can't open" file,10,10)
  33. call cleanup
  34. exit 20
  35. end
  36. buff = readch('in', 8)
  37. call close('in')
  38. select
  39. when left(buff,4) == 'ZOO ' then type = zoo
  40. when left(buff,4) == '$JGE' then type = ape
  41. when substr(buff,3,3) == '-lh' then type = lha
  42. when left(buff,2) == 'PK' then type = zip
  43. when left(buff,2) == '60'x||'EA'x then type = arj
  44. when left(buff,1) == '1A'x then type = arc
  45. otherwise do
  46. PutLog("Cannot handle" file,10,10)
  47. call cleanup
  48. exit 20
  49. end;end
  50.  
  51. if cmd.type=="" then do
  52. PutLog("Command unknown",10,10)
  53. call cleanup
  54. exit 20
  55. end
  56.  
  57. PutLog('Un'type'ing' files 'from' file,10,10)
  58. if GetClip('ASYNC') ~= 'TRUE' then address COMMAND packer.type cmd.type file files
  59. else address COMMAND packer.type '>NIL:' cmd.type file files
  60. arcode=RC
  61. call cleanup
  62. exit arcode
  63.  
  64. PutLog:  procedure expose log script
  65. if arg(3) < GetClip('STATUSLEVEL') then say arg(1)
  66. if arg(2) > GetClip('LOGLEVEL') then return 0
  67. if log then address 'ROOFLOG' 'logline' left(time(),5) script': 'arg(1)
  68. return 0
  69.  
  70. cleanup:
  71. if GetClip('ASYNC') = 'TRUE' then do
  72. aenum = GetCLip('ASYNCEVENT')
  73. if (aenum <= 1) then call SetCLip('ASYNCEVENT',"")
  74. else do
  75. aenum=aenum-1; call SetCLip('ASYNCEVENT',aenum)
  76. end;end
  77. return 0
  78.  
  79. /* Error Handling */
  80. halt:
  81. ioerr:
  82. break_c:
  83. call cleanup
  84. exit 10
  85.